package com.booksystem.campuslibrarymanagementsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.booksystem.campuslibrarymanagementsystem.entity.AccountTable;
import com.booksystem.campuslibrarymanagementsystem.entity.BooksTable;
import com.booksystem.campuslibrarymanagementsystem.entity.UserTable;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BooksTableMapper extends BaseMapper<BooksTable> {

    //查询-id
    @Select("select * from books_table where bookid = #{bookid}")
    BooksTable queryById(int bookid);

    //通过图书id修改名称，作者，类别
    @Update("update books_table set title = #{title},author = #{author},category = #{category} where bookid= #{bookid}")
    boolean upDataBook(int bookid, String title, String author, String category);

    //查询-名称
    @Select("select * from books_table where title = #{title}")
    List<BooksTable> selectBybooktitle(String title);
    //查询-名称

    @Select("select * from books_table where title = #{title}")
    BooksTable queryByTitle(String title);

    //删除
    @Delete("delete from books_table where bookid = #{bookid}")
    boolean deleteByBookid(int bookid);

    //获取最后一条数据的ids
    @Select("SELECT * FROM books_table ORDER BY bookid DESC LIMIT 1")
    BooksTable selectLastBookid();


    //动态查询（学号，名字，身份，状态）
    List<BooksTable> selectList(int bookid, String title, String author, String category);

    //通过图书id修改库存
    @Update("update books_table set totalcopies = #{totalcopies} where bookid= #{bookid}")
    boolean AddBook(int bookid, int totalcopies);

    @Select("SELECT * FROM books_table WHERE bookid = #{bookid} ")
    BooksTable add(int bookid);

    //动态查询（学号，名字，身份，状态）
    List<BooksTable> selectbookList(String title, String author, String category);

    //图书名称查询

    //查询-category
    @Select("select * from books_table where category = #{category}")
    List<BooksTable> queryByCategory(String category);

}
